package cool.webstudy.admin.service.impl;

import cool.webstudy.admin.service.OperationLoggerService;
import cool.webstudy.common.constant.LoggerConstant;
import cool.webstudy.common.model.dto.logger.opl.CreateOperationLogDBDTO;
import cool.webstudy.common.model.dto.logger.opl.CreateOperationLogESDTO;
import org.springframework.stereotype.Service;

/**
 * @author 莫振双
 * @date 2024/12/2 11:57
 * @description: 操作日志服务实现类
 */
@Service
public class OperationLoggerServiceImpl extends BaseLoggerServiceImpl implements OperationLoggerService {

    /**
     * 发送操作日志到数据库MQ
     *
     * @param dto 创建审计日志记录数据库数据模型
     * @return
     */
    @Override
    public Boolean sendOperationLogToDBMQ(CreateOperationLogDBDTO dto) {
        sendMessage(dto, LoggerConstant.OPL_LOG_DB_TOPIC,LoggerConstant.OPL_LOG_DB_TOPIC_KEY);
        return true;
    }

    /**
     * 发送操作日志到ES MQ
     *
     * @param dto 创建审计日志记录保存至ES数据模型
     * @return
     */
    @Override
    public Boolean sendOperationLogToESMQ(CreateOperationLogESDTO dto) {
        sendMessage(dto, LoggerConstant.OPL_LOG_ES_TOPIC, LoggerConstant.OPL_LOG_ES_TOPIC_KEY);
        return true;
    }
}
